feat(tools): add codebase_search and github_codebase_search tools#2474
feat(tools): add codebase_search and github_codebase_search tools#2474DhruvBhatia0 wants to merge 3 commits intoOpenHands:mainfrom
Conversation
Register Morph's WarpGrep as native OpenHands tools backed by the @morphllm/morphmcp MCP server. Users add Tool(name="codebase_search") to their agent like any other tool — the MCP plumbing is internal. - Two separate tool registrations sharing one MCP server process - edit_file from the MCP server is filtered out (FileEditorTool exists) - Clear ValueError with dashboard link when MORPH_API_KEY is missing - Pre-install @morphllm/morphmcp in Docker image for fast cold starts - README section + example at examples/01_standalone_sdk/45_codebase_search.py Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for the PR. Why a tool wrapping an mcp? Can we not just use the mcp directly? |
- Fix resolver signatures to match registry calling convention (conv_state=, **params) instead of (params: dict, conv_state: object) - Fix race condition: hold lock for entire MCP server start in _get_morph_search_tools - Add atexit handler to close cached MCP clients on process exit - Use (api_key, api_url, timeout_ms) tuple as cache key instead of just api_key - Add TYPE_CHECKING import for ConversationState - Use lazy %s logger formatting instead of f-string - Add docstring note explaining callable resolver pattern - Exclude 45_codebase_search.py from CI example tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ah good point, i can make this change, |
Replace the MCP-based approach (which wrapped @morphllm/morphmcp) with direct calls to @morphllm/morphsdk via a Node.js bridge script. - Native ToolDefinition subclasses with proper Action/Observation schemas - bridge.js calls WarpGrepClient.execute() and searchGitHub() directly - No more MCP server process, shared client cache, or atexit cleanup - Clear error messages for missing Node.js, missing SDK, missing API key - Dockerfile installs @morphllm/morphsdk instead of @morphllm/morphmcp Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
If this is just an MCP server, which we already support, why do we need a new tool instead of using the MCP directly (i.e., passing it to the agent)? Moreover, we already have tools that allow the agent to explore the codebase. Why would this tool be better? Is there a related issue for this? |
|
[Automatic Post]: I have assigned @enyst as a reviewer based on git blame information. Thanks in advance for the help! |
| :func:`_resolver_from_callable` in ``openhands.sdk.tool.registry``. | ||
| Registers ``codebase_search`` and ``github_codebase_search`` as native | ||
| OpenHands tools. Each tool calls ``@morphllm/morphsdk`` via a small | ||
| Node.js bridge script (``bridge.js``), which handles the multi-turn |
There was a problem hiding this comment.
I'd love to know the answer to Vasco's question, I'm not sure a bridge is necessary if it's MCP?
|
[Automatic Post]: It has been a while since there was any activity on this PR. @DhruvBhatia0, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
1 similar comment
|
[Automatic Post]: It has been a while since there was any activity on this PR. @DhruvBhatia0, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. |
Summary
@morphllm/morphmcpMCP serverTool(name="codebase_search")to their agent like any other tool — MCP plumbing is internalcodebase_search+github_codebase_search) sharing one MCP server processedit_filefrom the MCP server is filtered out to avoid conflict withFileEditorToolValueErrorwith dashboard link whenMORPH_API_KEYis missing@morphllm/morphmcpin Docker image for fast cold startsUsage
Requires
MORPH_API_KEYenv var (or passed viaTool(name="codebase_search", params={"api_key": "sk-..."})) and Node.js 18+.Test plan
list_registered_tools()MORPH_API_KEYraisesValueErrorwith instructions + dashboard linkfrom openhands.tools import register_codebase_search_toolsworksMORPH_API_KEYset against a real repo@morphllm/morphmcppre-installed🤖 Generated with Claude Code